<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>查询通讯录</title>
    <style>
        body{text-align: center;width: 100%;}
        a{ color: gray; text-decoration: none;}
        a:hover{ color:red;}
        .new{ text-align: right; width:1000px;padding-bottom: 10px;}
        h1{ color:cornflowerblue;}
        table{ width:480px; border:4px double red; border-spacing: 0;margin: auto;}
        th, td{ border-bottom: 1px dotted darkgreen; border-right: 1px dotted darkgreen; padding: 6px 10px;}
    </style>
</head>
<body>
<h1>通讯录信息</h1>
<div class="new"><a href="new.php">注册新用户</a></div>
<?php
$db=new PDO("mysql:host=localhost; dbname=db2;", 'root', '12qwas');
$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE,PDO::FETCH_ASSOC);
$ps=$db->query('select * from students');
echo "<table>";
echo '<tr><th>学号</th><th>姓名</th><th>电话</th><th>管理</th></tr>';
foreach ($ps as $r) {
    echo "<tr><td>{$r['xh']}</td><td>{$r['name']}</td><td>{$r['tel']}</td><td><a href='delete.php?xh={$r['xh']}'>删除</a> </td></tr>";
}
echo '</table>'
?>
</body>
</html>
